package com.wjs.pool;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class excutorPoolDemo {
    public static void main(String[] args) {
//        ExecutorService pool = Executors.newFixedThreadPool(5);
//        ExecutorService pool = Executors.newSingleThreadExecutor();
        ExecutorService pool = Executors.newCachedThreadPool();
        try {
            for (int i = 1; i <= 10; i++) {
                pool.execute(()->{
                    System.out.println(Thread.currentThread().getName()+"处理了业务");
                });
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            pool.shutdown();
        }
    }
}
